# member operator - index
# 从左往右, 0->1->2->3
# 从右往左, -1->-2->-3->-4
ms = "1234567890"
print(ms[0])  # 1
print(ms[1])  # 2
print(ms[2])  # 3
print(ms[3])  # 4
print(ms[4])  # 5
print(ms[5])  # 6
print(ms[6])  # 7
print(ms[7])  # 8
print(ms[8])  # 9
print(ms[9])  # 0
print(ms[-1])  # 0
print(ms[-2])  # 9
print(ms[-3])  # 8
print(ms[-4])  # 7
print(ms[-5])  # 6
print(ms[-6])  # 5
print(ms[-7])  # 4
print(ms[-8])  # 3
print(ms[-9])  # 2
print(ms[-10])  # 1
print("----------------------------------- ")


# slice: 包前不包后
mss = "abcdefghijk"

# 从左往右
print("-----------从左往右----------------- ")
print(mss[0:3])  # abc
print(mss[3:6])  # def
print(mss[6:9])  # ghi
print(mss[9:12])  # jki
print(mss[0:12])  # abcdefghijk
print(mss[0:12:2])  # acdegijk
print(mss[0:12:3])  # adg
print(mss[0:12:4])  # aei

print("-----------从右往左----------------- ")
# 从右往左
# 步长的绝对值大小决定切取的间隔,正负号决定切取方向/
# 正数表示从左往右取值, 负数表示从右往左取值
mss2 = "abcdefghijk"

print(mss2[-1::1])  # k
print(mss2[-1:-5:-1])  # kjih
print(mss2[0:7:2])  # aceg
